package com.cater.talents.service;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cater.common.BaseEntity;
import com.cater.common.PageResult;
import com.cater.query.CommonQuery;
import com.cater.sys.service.BaseService;
import com.cater.talents.dao.WorkSearchDao;
import com.cater.talents.entity.WorkSearch;

/**
 * 描述：工作记录表 服务实现层
 * 
 * @author yong
 * @date 2019/1/5
 */
@Service
public class WorkSearchServiceImpl implements BaseService<WorkSearch, CommonQuery, String> {

	@Autowired
	WorkSearchDao dao;

	@Override
	public PageResult<WorkSearch> findPageResult(CommonQuery query) {
		PageResult<WorkSearch> result = new PageResult<WorkSearch>();
		result.setPage(query.getPage());
		result.setPageSize(query.getRows());
		int count = dao.findCount(query);
		int first = (query.getPage() - 1) * query.getRows();
		int max = query.getRows();
		List<WorkSearch> list = dao.findList(query, first, max);
		result.setRows(list);
		result.setRecords(count);
		return result;
	}

	@Override
	public List<WorkSearch> getAll() {
		return dao.getAll();
	}

	@Override
	public List<WorkSearch> getAllCommon(CommonQuery query) {
		return dao.getAllCommon(query);
	}

	@Override
	public int save(WorkSearch t) {
		return 0;
	}

	@Override
	public String saves(WorkSearch t) {
		t.setId(UUID.randomUUID().toString().replaceAll("-", ""));
		BaseEntity.getCreate(t);
		dao.save(t);
		return t.getId();
	}

	@Override
	public void update(WorkSearch t) {
		BaseEntity.getupdate(t);
		dao.update(t);
	}

	@Override
	public void delete(String id) {
		dao.delete(id);
	}

	@Override
	public WorkSearch getById(String id) {
		return dao.getById(id);
	}

	public void insertList(List<WorkSearch> workSearchs) {
		dao.insertList(workSearchs);
	}

	public void deleteList(String[] ids) {
		dao.deleteList(ids);
	}

	public List<Map<String, String>> getCount(CommonQuery query) {
		return dao.getCount(query);
	}

	public List<WorkSearch> getListBy(CommonQuery query) {
		return dao.getListBy(query);
	}

	public WorkSearch checkUnique(CommonQuery query) {
		return dao.checkUnique(query);
	}
}